package com.cm.etax.tianjin.bean;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * 天津市电子税务局统一身份认证 Ajax 响应对象
 *
 * @author LWang 2023.02.01
 * @since 1.0.0
 */
@Data
public class SysApiResponse {
    /**
     * 响应码
     */
    private int code;
    /**
     * 响应消息
     */
    private String msg;
    /**
     * 压缩码
     */
    private String zipCode;
    /**
     * 加密码
     */
    private String encryptCode;
    /**
     * 响应数据
     */
    private String datagram;
    /**
     * 签名类型
     */
    private String signtype;
    /**
     * 签名
     */
    private String signature;
    /**
     * 响应时间戳
     */
    private String timestamp;

    protected static final int SUCCESS_CODE = 1000;

    protected static final String DEFAULT_MESSAGE = "网络异常！";

    public boolean success() {
        return SUCCESS_CODE == this.getCode();
    }

    public String msg() {
        return StringUtils.isBlank(this.getMsg()) ? DEFAULT_MESSAGE : this.getMsg();
    }
}
